package com.design3.graduatethesissys.mapper;

import java.util.Map;

import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import com.design3.graduatethesissys.domain.Regist;
import com.design3.graduatethesissys.domain.Student;

/** 
* @author 作者 罗穆健: 
* @version 创建时间：2020年1月9日 下午6:14:52 
* 类说明 
*/
@Mapper
public interface StudentMapper {

	@Update("update student set stu_subject = #{sbj_id} , stu_status='st02' where stu_id = #{username}")
	void UpdateStuSubjectByStudentId(String username, String sbj_id);

	@Insert("Insert into student (stu_id,stu_name,stu_sex,stu_phone,stu_mail,stu_status) values(#{stu_id},#{stu_name},#{stu_sex},#{stu_phone},#{stu_mail},#{stu_status})")
	void InsertStudent(Regist regist);

	@Select("SELECT\r\n" + 
			"	te.teh_id,\r\n" + 
			"	te.teh_name \r\n" + 
			"FROM\r\n" + 
			"	teacher te\r\n" + 
			"	LEFT JOIN teacher_student_subject sts ON te.teh_id = sts.teh_id\r\n" + 
			"	LEFT JOIN student st ON st.stu_id = sts.stu_id \r\n" + 
			"WHERE\r\n" + 
			"	st.stu_id = #{userName}")
	Map<String, Object> getTeacher(String userName);

	@Select("Select stu_status from student where stu_id = #{userName}")
	Map<String, Object> searchStatus(String userName);

	@Update("update student set stu_mail = #{stu_mail}, stu_phone = #{stu_phone} where stu_id = #{stu_id}")
	void updateStudent(Student student);

	@Select("Select stu_id,stu_name,stu_sex,stu_mail,stu_phone from student where stu_id = #{stu_id}")
	Student getStudent(String stu_id);

	
	
}
 